#if !defined(AFX_DLGCONFIGCHARSET_H__076CFCDD_89A0_4B2A_9A7F_5DF4743AEE45__INCLUDED_)
#define AFX_DLGCONFIGCHARSET_H__076CFCDD_89A0_4B2A_9A7F_5DF4743AEE45__INCLUDED_

#include "MySplitter.h"	// Added by ClassView
#include "ResizeGripper.h"	// Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DlgConfigCharSet.h : header file
//
#include "MyEdit.h"

#define WM_CHARSET_LB_RBUTTONUP WM_USER + 1024
#define WM_CHARSET_LB_REORDERED	WM_USER + 1025

/////////////////////////////////////////////////////////////////////////////
// CCharSetListBox

class CCharSetListBox : public CDragListBox
{
public:
	virtual void Dropped( int nSrcIndex, CPoint pt )
	{
		DrawInsert(-1);
		int nDestIndex = ItemFromPt(pt);

		if (nSrcIndex == -1 || nDestIndex == -1)
			return;
		if (nDestIndex == nSrcIndex || nDestIndex == nSrcIndex+1)
			return; //didn't move
		CString str;
		DWORD dwData;
		GetText(nSrcIndex, str);
		dwData = GetItemData(nSrcIndex);
		DeleteString(nSrcIndex);
		if (nSrcIndex < nDestIndex)
			nDestIndex--;
		nDestIndex = InsertString(nDestIndex, str);
		SetItemData(nDestIndex, dwData);
		CDragListBox::SetCurSel(nDestIndex);
		pParent->SendMessage(WM_CHARSET_LB_REORDERED);
	}
	void RenameString(int nIndex, CString sString)
	{
		DWORD dwData;
		dwData = GetItemData(nIndex);
		DeleteString(nIndex);
		nIndex = InsertString(nIndex, sString);
		SetItemData(nIndex, dwData);
	}
	int SetCurSel(int nSelect)
	{
		if(nSelect == GetCurSel() && nSelect != -1)
		{
			return -1;
		}
		int nResult = CDragListBox::SetCurSel(nSelect);
		pParent->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), LBN_SELCHANGE), (LPARAM)m_hWnd);
		return nResult;
	}
	CWnd *pParent;

	// Generated message map functions
protected:
	//{{AFX_MSG(CCharSetListBox)
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
// CDlgConfigCharSet dialog

class CDlgConfigCharSet : public CDialog
{
// Construction
public:
	void Save();
	CDlgConfigCharSet(CWnd* pParent = NULL);   // standard constructor
	
	// Dialog Data
	//{{AFX_DATA(CDlgConfigCharSet)
	enum { IDD = IDD_CONFIG_CHARSET };
	CEdit	m_txtCharsetName;
	CButton	m_btnOK;
	CButton	m_btnCancel;
	CMyEdit	m_txtChars;
	CCharSetListBox	m_listCharsetName;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CDlgConfigCharSet)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	BOOL m_bSaved;
	void SaveCurCharSet();
	BOOL m_bDirty;
	BOOL IsDirty();
	void RenameCharSet(int nIndex);
	CArray <CString*, CString* > m_arrChars;
	void LoadCharSets();
//	CToolBarCtrl m_tb;
	HICON m_hIcon;
//	CFont m_charfont;
//	CResizeGripper m_gripper;
	BOOL m_bInited;
	void RecalcLayout();
	CMySplitter m_splitter;

	// Generated message map functions
	//{{AFX_MSG(CDlgConfigCharSet)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	virtual BOOL OnInitDialog();
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
	afx_msg void OnUpdateDeleteCharset(CCmdUI* pCmdUI);
	afx_msg void OnUpdateRenameCharset(CCmdUI* pCmdUI);
	afx_msg void OnUpdateSave(CCmdUI* pCmdUI);
	afx_msg void OnHelp();
	afx_msg void OnUpdateMoveup(CCmdUI* pCmdUI);
	afx_msg void OnUpdateMovedown(CCmdUI* pCmdUI);
	afx_msg void OnSelchangeListCharsetName();
	afx_msg void OnDestroy();
	afx_msg void OnAddCharset();
	afx_msg void OnDblclkListCharsetName();
	afx_msg void OnKillfocusTxtCharsetName();
	afx_msg void OnDeleteCharset();
	afx_msg void OnSave();
	afx_msg void OnClose();
	virtual void OnCancel();
	virtual void OnOK();
	afx_msg void OnQuit();
	//}}AFX_MSG
	afx_msg LRESULT OnSplitterMoved(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnCharSetLbRButtonUp(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnCharSetLbReOrdered(WPARAM wParam, LPARAM lParam);
	
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DLGCONFIGCHARSET_H__076CFCDD_89A0_4B2A_9A7F_5DF4743AEE45__INCLUDED_)
